﻿using System;
using NUnit.Framework;

namespace cshape_demo
{
    [TestFixture]
    public class ClassInherit
    {
        [Test]
        public void TestInherit()
        {
            Cat cat = new Cat("小花", true, "黄色");
            // 无法直接访问到父类的属性
            // cat.name;
            Console.WriteLine(cat);
            // 通过继承到的方法修改父类的属性
            cat.SetName("小红");
            // 通过自己的方法来修改
            cat.SetSex(false);
            Console.WriteLine(cat);
        }
    }

    public class Animal
    {
        protected String name;

        protected bool sex;

        public Animal(String name, bool sex)
        {
            this.name = name;
            this.sex = sex;
        }
        
        public void SetName(String name)
        {
            this.name = name;
        }

    }

    public class Cat : Animal
    {

        public String coatColor;

        public Cat(string name, bool sex, string coatColor) : base(name, sex)
        {
            this.coatColor = coatColor;
        }

        public override string ToString()
        {
            return $"{base.name}, {base.sex}, {this.coatColor}";
        }

        public void SetSex(bool sex)
        {
            base.sex = sex;
        }

    }
}